package org.nfIt.controller;

import org.nfIt.entity.system.SysMenu;
import org.nfIt.service.SysMenuService;
import org.nfIt.vo.common.Result;
import org.nfIt.vo.common.ResultCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ClossName:SysMenuController
 * Pakage:org.nfIt.controller
 * Description
 *
 * 菜单管理
 *
 * @Author L
 * @Create 2024/6/24 19:16
 * @Version 2023.1.3
 */
@RestController
@RequestMapping(value="/admin/system/sysMenu")
public class SysMenuController {

    @Autowired
    private SysMenuService sysMenuService;

    /**
     * 菜单列表查询
     */
    @GetMapping("/findNodes")
    public Result<List<SysMenu>> findNodes() {
        List<SysMenu> list = sysMenuService.findNodes();
        return Result.build(list , ResultCodeEnum.SUCCESS) ;
    }

    /**
     * 添加菜单
     * @param sysMenu
     */
    @PostMapping("/save")
    public Result save(@RequestBody SysMenu sysMenu) {
        sysMenuService.save(sysMenu);
        return Result.build(null , ResultCodeEnum.SUCCESS) ;
    }

    /**
     * 菜单修改
     * @param sysMenu 实体
     */
    // com.atguigu.spzx.manager.controller#SysMenuController
    @PutMapping("/updateById")
    public Result updateById(@RequestBody SysMenu sysMenu) {
        sysMenuService.updateById(sysMenu);
        return Result.build(null , ResultCodeEnum.SUCCESS) ;
    }

    /**
     * 菜单删除
     * @param id 菜单id
     * @return
     */
    // com.atguigu.spzx.manager.controller#SysMenuController
    @DeleteMapping("/removeById/{id}")
    public Result removeById(@PathVariable Long id) {
        sysMenuService.removeById(id);
        return Result.build(null , ResultCodeEnum.SUCCESS) ;
    }

}
